package com.yasha.sharingnews;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.yasha.model.News;

public class ViewPostActivity extends Activity implements OnClickListener {

	private TextView txt_title, txt_content;
	private Button btn_share, btn_set_rank, btn_call, btn_sms, btn_control,
			btn_road, btn_report;
	private String title = "";
	private News news;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_view_post);

		txt_title = (TextView) findViewById(R.id.txt_view_post_title);
		txt_content = (TextView) findViewById(R.id.txt_view_content);

		btn_share = (Button) findViewById(R.id.btn_view_share_fb);
		btn_set_rank = (Button) findViewById(R.id.btn_view_set_rank);
		btn_call = (Button) findViewById(R.id.btn_view_call);
		btn_sms = (Button) findViewById(R.id.btn_view_sms);
		btn_control = (Button) findViewById(R.id.btn_view_control);
		btn_road = (Button) findViewById(R.id.btn_view_road);
		btn_report = (Button) findViewById(R.id.btn_view_report);

		btn_share.setOnClickListener(this);
		btn_set_rank.setOnClickListener(this);
		btn_call.setOnClickListener(this);
		btn_sms.setOnClickListener(this);
		btn_control.setOnClickListener(this);
		btn_road.setOnClickListener(this);
		btn_report.setOnClickListener(this);

		Bundle data = getIntent().getExtras();
		title = data.getString("title").trim();
		if (MainPageActivty.data != null && MainPageActivty.data.size() > 0)
			for (int i = 0; i < MainPageActivty.data.size(); i++) {
				if (title.equals(MainPageActivty.data.get(i).getTitle().trim())) {
					news = MainPageActivty.data.get(i);
					
					txt_title.setText(news.getTitle());
					txt_content.setText(news.getContent());
					
					
					break;
				}
			}
		else {
			Toast.makeText(this, getString(R.string.empty_data),
					Toast.LENGTH_LONG).show();
		}
	}

	@Override
	public void onClick(View v) {
		int id = v.getId();
		switch (id) {
		case R.id.btn_view_share_fb: // 1

			break;
		case R.id.btn_view_set_rank: // 2

			break;
		case R.id.btn_view_call: // 3

			break;
		case R.id.btn_view_sms: // 4

			break;
		case R.id.btn_view_control: // 5

			break;
		case R.id.btn_view_road: // 6

			break;
		case R.id.btn_view_report:// 7

			break;
		default:
			break;
		}
	}
}
